package com.gaohe.projectException;

import com.gaohe.utils.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ProjectExceptionHandler {

    //定义拦截的异常类型
//    @ExceptionHandler(RuntimeException.class)
//    public Result myException(Exception e){
//        System.out.println("遇到异常了");
//        return new Result(5000,null,e.getMessage());
//    }
    @ExceptionHandler(BusinessException.class)
    public Result doBusiness(BusinessException be){
        return new Result(be.getCode(),null, be.getMessage());
    }

}
